/**
 * The frame contains a content window as a child window.
 * It usually uses to wrap content GUI by some type of graphic border or frame.
 * Also it can be used as a proxy for the content object.
 *
 * @author Andrey Anisimov <hercules@inbox.ru>
 */

import core.ui.Window;

class Frame extends Window {
	
	/**
	 * Creates new frame window.
	 * 
	 * @param parent (Window) [optional] parent window
	 * @param x, y (int) [optional] coordinates
	 * @param width, height (int) [optional] window size.
	 */	
	this.Frame = function(parent, x, y, width, height) {
		super(parent, x, y, width, height);
		this.setStyle('overflow', 'visible');
	}
	
	/**
	 * Sets the content window for this frame.
	 *
	 * @param wnd (Window) content window (should be a child).
	 */
	this.setContentWindow = function(wnd) {
		this.content = wnd;
		var width = this.getWidth() - this.getClientWidth() + wnd.getWidth();
		this.setStyle('width', width + 'px');
	}
	
	/**
	 * Returns content window within this frame.
	 * 
	 * @return Window
	 */
	this.getContentWindow = function() {
		return this.content;
	}
	
	this.onmousedown = function() {
		this.activate();
	}
}